package day18.pack2;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Test {
    public static void main(String[] args) throws Exception {
        printerAnyClassFiledAndMethod("day18.pack2.Student");
    }

    public static void printerAnyClassFiledAndMethod(String path) throws Exception {
        // 获取class
        Class<?> clazz = Class.forName(path);
//        clazz.getFields(); // 包含父类
        Field[] fields = clazz.getDeclaredFields(); // 获取自身类的属性
        for (Field field : fields) {
            System.out.print(field.getName() + ", ");
        }
//        clazz.getMethods(); // 包含父类
        Method[] methods = clazz.getDeclaredMethods();
        for (Method method : methods) {
            System.out.print(method.getName() + ", ");
        }
    }
}
